package com.jinandi.app.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.transaction.annotation.Transactional;

import com.jinandi.app.domain.Authorit;

public interface AuthorityDao extends JpaSpecificationExecutor<Authorit>, JpaRepository<Authorit, Integer> , PagingAndSortingRepository<Authorit, Integer>{

	/**
	 * <根据ID查询出角色>
	 * @param id
	 * @return
	 * @author CGC 
	 * 创建日期:2013-5-9 下午1:35:03
	 */
	Authorit findAuthoritById(Long id);

	/**
	 * <根据ID删除角色>
	 * @param id
	 * @author CGC 
	 * 创建日期:2013-5-9 下午1:35:27
	 */
	@Modifying
	@Transactional
	@Query("delete from Authorit where id = ?1")
	void deleteAuthoritById(Long id);

	/**
	 * <查询角色列表>
	 * @return
	 * @author CGC 
	 * 创建日期:2013-5-9 下午1:35:57
	 */
	@Query(value = "SELECT id, auName FROM JND_AUTHORIT", nativeQuery = true)
	List<Object[]> getAuthorit();

}
